//3074.重新分装苹果
//https://leetcode.cn/problems/apple-redistribution-into-boxes/
class Solution {
public:
    int minimumBoxes(vector<int>& apple, vector<int>& capacity) {
        sort(capacity.begin(),capacity.end(),greater<int>());

        int ret = 0;
        int sum = 0;
        for(int n:apple) sum += n;

        if(sum <= capacity.front()) return 1;
        for(int n:capacity)
        {
            ++ret;
            sum -= n;
            if(sum <= 0) return ret;
        }
        return 0;
    }
};